<?php
define('DRUPAL_ROOT', getcwd());

require_once DRUPAL_ROOT . '/includes/bootstrap.inc';

drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
     // force download  
   # header("Content-Type: application/force-download");
  #  header("Content-Type: application/octet-stream");
  #  header("Content-Type: application/download");
header("Content-type: text/xml");
$last_event=db_select("node","n")->condition('type','event')->fields("n",array('changed'))->orderBy('changed','DESC')->execute()->fetch();
$last_place=db_select("node","n")->condition('type','place')->fields("n",array('changed'))->orderBy('changed','DESC')->execute()->fetch();
$last_gallery=db_select("node","n")->condition('type','media_gallery')->fields("n",array('changed'))->orderBy('changed','DESC')->execute()->fetch();
$last_newarticle=db_select("node","n")->condition('type','newarticle')->fields("n",array('changed'))->orderBy('changed','DESC')->execute()->fetch();
#print_r($last_gallery);
    // disposition / encoding on response body
   # header("Content-Disposition: attachment;filename=infopark_".date('dmY').".xml");
  #  header("Content-Transfer-Encoding: binary");
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
echo '<?xml version="1.0" encoding="UTF-8"?>';
?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
   <url>
      <loc>http://<?=$_SERVER['SERVER_NAME'];?>/events</loc>
      <lastmod><?=date('Y-m-d',$last_event->changed);?></lastmod>
      <changefreq>weekly</changefreq>
      <priority>1.0</priority>
   </url>
    <url>
      <loc>http://<?=$_SERVER['SERVER_NAME'];?>/events/engine</loc>
      <lastmod><?=date('Y-m-d',$last_event->changed);?></lastmod>
      <changefreq>weekly</changefreq>
      <priority>1.0</priority>
   </url>
    <url>
      <loc>http://<?=$_SERVER['SERVER_NAME'];?>/places</loc>
      <lastmod><?=date('Y-m-d',$last_event->changed);?></lastmod>
      <changefreq>monthly</changefreq>
      <priority>0.8</priority>
   </url>
    <url>
      <loc>http://<?=$_SERVER['SERVER_NAME'];?>/gallery-collections/galleries</loc>
      <lastmod><?=date('Y-m-d',$last_gallery->changed);?></lastmod>
      <changefreq>weekly</changefreq>
      <priority>0.8</priority>
   </url>
    <url>
      <loc>http://<?=$_SERVER['SERVER_NAME'];?>/news</loc>
      <lastmod><?=date('Y-m-d',$last_newarticle->changed);?></lastmod>
      <changefreq>weekly</changefreq>
      <priority>0.8</priority>
   </url>
</urlset>